<template>
  <div id="data-view">
    <dv-border-box-1 :color="['red', 'green']">
      <div class="main-header">
        <div class="mh-right">
          <dv-border-box-2
            style="
              width: 120px;
              height: 50px;
              line-height: 50px;
              text-align: center;
              margin-left: 200px;
            "
          >
            综合管理台
          </dv-border-box-2>
        </div>
      </div>

      <dv-border-box-1 class="main-container">
        <dv-border-box-3 class="left-chart-container">
          <Left-Chart-1 />
          <Left-Chart-2 />
          <Left-Chart-3 />
        </dv-border-box-3>

        <div class="right-main-container">
          <div class="rmc-top-container">
            <dv-border-box-3 class="rmctc-left-container">
              <Center-Cmp />
            </dv-border-box-3>

            <div class="rmctc-right-container">
              <dv-border-box-3 class="rmctc-chart-1">
                <Right-Chart-1 />
              </dv-border-box-3>

              <dv-border-box-4 class="rmctc-chart-2" :reverse="true">
                <Right-Chart-2 />
              </dv-border-box-4>
            </div>
          </div>

          <dv-border-box-4 class="rmc-bottom-container">
            <Bottom-Charts />
          </dv-border-box-4>
        </div>
      </dv-border-box-1>
    </dv-border-box-1>
  </div>
</template>

<script setup>
import LeftChart1 from './components/LeftChart1.vue'
import LeftChart2 from './components/LeftChart2.vue'
import LeftChart3 from './components/LeftChart3.vue'

import CenterCmp from './components/CenterCmp.vue'

import RightChart1 from './components/RightChart1.vue'
import RightChart2 from './components/RightChart2.vue'

import BottomCharts from './components/BottomCharts.vue'

import { ref,onUnmounted } from 'vue';

const isFullScreen = ref(false);

const toggleFullScreen = () => {
  if (!document.fullscreenElement && !isFullScreen.value) {
    // 当前不是全屏模式，尝试进入全屏
    enterFullScreen();
  } else {
    // 当前是全屏模式，退出全屏
    exitFullScreen();
  }
};

const enterFullScreen = async () => {
  try {
    await document.documentElement.requestFullscreen();
    isFullScreen.value = true;
  } catch (err) {
    console.error(`Error attempting to enable full-screen mode: ${err.message} (${err.name})`);
  }
};

const exitFullScreen = async () => {
  try {
    if (document.exitFullscreen) {
      await document.exitFullscreen();
      isFullScreen.value = false;
    }
  } catch (err) {
    console.error(`Error attempting to disable full-screen mode: ${err.message} (${err.name})`);
  }
};

// 监听全屏变化事件
document.addEventListener('fullscreenchange', () => {
  isFullScreen.value = !!document.fullscreenElement;
});

// 清理监听器
onUnmounted(() => {
  document.removeEventListener('fullscreenchange', () => {
    isFullScreen.value = !!document.fullscreenElement;
  });
});
</script>

<style>
#data-view {
  width: 100%;
  height: 100%;
  background-color: #030409;
  color: #fff;
}

#data-view {
  background-image: url('@/assets/images/data-bg.png');
  background-size: 100% 100%;
  box-shadow: 0 0 3px blue;
  display: flex;
  flex-direction: column;
}

#data-view .main-header {
  height: 80px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

#data-view .main-header .mh-left {
  font-size: 20px;
  color: rgb(1, 134, 187);
}

#data-view .main-header .mh-left a:visited {
  color: rgb(1, 134, 187);
}

#data-view .main-header .mh-middle {
  font-size: 30px;
}

#data-view .main-header .mh-left,
#data-view .main-header .mh-right {
  width: 450px;
}

#data-view .main-container {
  height: calc(100% - 80px);
}

#data-view .main-container .border-box-content {
  padding: 20px;
  box-sizing: border-box;
  display: flex;
}

#data-view .left-chart-container {
  width: 22%;
  padding: 10px;
  box-sizing: border-box;
}

#data-view .left-chart-container .border-box-content {
  flex-direction: column;
}

#data-view .right-main-container {
  width: 78%;
  padding-left: 5px;
  box-sizing: border-box;
}

#data-view .rmc-top-container {
  height: 65%;
  display: flex;
}

#data-view .rmc-top-container .rmctc-left-container {
  width: 65%;
}

#data-view .rmc-top-container .rmctc-right-container {
  width: 35%;
}

#data-view .rmc-bottom-container {
  height: 35%;
}

#data-view .rmc-top-container .rmctc-chart-1,
#data-view .rmc-top-container .rmctc-chart-2 {
  height: 50%;
}
</style>
